import { IsString, IsArray, IsNumber, IsOptional, ValidateNested } from 'class-validator';
import { Type } from 'class-transformer';
import { ApiProperty } from '@nestjs/swagger';
import { PagingDto } from 'src/common/dto/index';

export class FileDto {
  @ApiProperty({ description: '文件名' })
  @IsString()
  name: string;

  @ApiProperty({ description: '阿里云key' })
  @IsString()
  key: string;
}

export class TaskInfoDto {
  @ApiProperty({ description: '任务类型' })
  @IsString()
  task_type: string;

  @ApiProperty({ description: '标签列表' })
  @IsArray()
  @IsString({ each: true })
  tags: string[];

  @ApiProperty({ description: '任务ID' })
  @IsString()
  task_id: string;
}

export class FolderInfoDto {
  @ApiProperty({ description: '预期文件数量' })
  @IsNumber()
  expected_file_count: number;

  @ApiProperty({ description: '已上传文件数量' })
  @IsNumber()
  uploaded_file_count: number;

  @ApiProperty({ description: '文件夹ID' })
  @IsNumber()
  folder_id: number;
}

export class CreateNotifyDto {
  @ApiProperty({ description: '通知ID' })
  @IsNumber()
  id: number;

  @ApiProperty({ description: '通知类型' })
  @IsString()
  notify_type: string;

  @ApiProperty({ description: '组织UUID' })
  @IsString()
  org_id: string;

  @ApiProperty({ description: '项目UUID' })
  @IsString()
  prj_id: string;

  @ApiProperty({ description: '设备SN' })
  @IsString()
  sn: string;

  @ApiProperty({ description: '任务信息' })
  @ValidateNested()
  @Type(() => TaskInfoDto)
  task_info: TaskInfoDto;

  @ApiProperty({ description: '文件列表' })
  @ValidateNested({ each: true })
  @Type(() => FileDto)
  @IsArray()
  files: FileDto[];

  @ApiProperty({ description: '文件夹信息' })
  @ValidateNested()
  @Type(() => FolderInfoDto)
  folder_info: FolderInfoDto;
}

export class ListNotifyDto extends PagingDto {
  @ApiProperty({ required: false })
  @IsOptional()
  @IsString()
  notify_type?: string;

  @ApiProperty({ required: false })
  @IsOptional()
  @IsString()
  org_id?: string;

  @ApiProperty({ required: false })
  @IsOptional()
  @IsString()
  task_id?: string;
}

export class UpdateNotifyDto extends CreateNotifyDto {
  @ApiProperty({ description: '通知ID' })
  @IsNumber()
  id: number;
} 